package com.us.proframe.utils;

import com.us.proframe.vo.ResultVo;

/**
 * 处理返回结果的封装.
 * User: lyh
 * Date: 2017/8/9
 * Time: 16:06
 */
public class ResultUtil {

    /**
     * 封装返回失败的信息
     * @param code  错误代码
     * @param message 错误信息
     * @return ResultVo
     * */
    public static ResultVo error(Integer code,String message){
        ResultVo result = new ResultVo();
        result.setCode(code);
        result.setMessage(message);
        return result;
    }

    /**
     * 封装返回成功的信息
     * @return ResultVo
     * */
    public static ResultVo success(Object data){
        ResultVo result = new ResultVo();
        result.setCode(0);
        result.setMessage("成功");
        result.setData(data);
        return result;
    }

    /**
     * 封装返回成功的信息
     * @return ResultVo
     * */
    public static ResultVo success(){
        ResultVo result = new ResultVo();
        result.setCode(0);
        result.setMessage("成功");
        return result;
    }
}
